<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Pragma" content="no-cache"> 
	<meta http-equiv="Cache-Control" content="no-cache"> 
	<meta http-equiv="Expires" content="0"> 
	<title>PRESSURE</title>
	<link rel="stylesheet" type="text/css" href="../js/easyui/themes/bootstrap/easyui.css">
	<link rel="stylesheet" type="text/css" href="../js/easyui/themes/icon.css">
	<script type="text/javascript" src="../js/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../js/extEasyUI.js?v=201305241044" charset="utf-8"></script>
	<script type="text/javascript" src="../js/extJquery.js?v=201305301341" charset="utf-8"></script>

	
	<script type="text/javascript">
	
		var intv;
		var intvSimu;

		$(function() {
			
			//load();
			
			loadRuntime();
			
			
			$('#fsimu').form({
			    onLoadError: function(){
					// do some check
					// return false to prevent submit;
			    }
			});
			
			
			loadSimu();
			
			intv = setInterval(loadRuntime, 1000);
									
		});
		
		function loadRuntime() {
			
			$.ajax({ 
		        type: "post", 
                url: '../boss/runtime.do',
                dataType: "json",
                success: function (data) {
                	//$('#runtime').val(data.data);
                	$('#runtime').textbox("setText", data.data);
                },
                error: function () {
                	$('#runtime').textbox("setText", "");
                }
			});
			
		}
						
		function start(){
			
			$.messager.progress();
			
			$('#enabled').val("true");
			
			$('#fsimu').form('submit', {
				url:'../simu/set.do',
				success: function(){
					$.messager.progress('close');	// hide progress bar while submit successfully
					intvSimu = setInterval(loadSimu, 5000);
				}
			});
			
		}
		
		function stop(){
			
			$.messager.progress();
			
			$('#enabled').val("false");
			
			$('#fsimu').form('submit', {
				url:'../simu/set.do',
				success: function(){
					$.messager.progress('close');	// hide progress bar while submit successfully
					clearInterval(intvSimu);
				}
			});
			
		}		
		
		function loadSimu(){
			
			$.messager.progress();
			$('#fsimu').form('load', '../simu/get.do');
			$.messager.progress('close');
			
		}
		
		function upBase() {
			
			$.ajax({ 
		        type: "post", 
                url: '../simu/upBase.do',
                dataType: "json",
                success: function(){
                	loadSimu();
				}
			});
			
		}	
		
		function downBase() {
			
			$.ajax({ 
		        type: "post", 
                url: '../simu/downBase.do',
                dataType: "json",
                success: function(){
                	loadSimu();
				}
			});
			
		}			
		
	</script>
	
	
</head>
<body>

	<div style="margin:5px 0;"></div>
		
	<div class="easyui-panel" title="数据模拟" style="width:600px">
	
		<div style="padding:5px 60px 5px 60px">

		    <form id="fsimu" method="post">
		    	<table>
		    		<tr>
		    			<td>单次数量:</td>
		    			<td>
		    				<input name="number" type="text" value="">
						</td>
		    		</tr>		    	
		    		<tr>
		    			<td>单次间隔:</td>
		    			<td>
		    				<input name="interval" type="text" value="">
						</td>
						<td>毫秒</td>
		    		</tr>		    	
		    		<tr>
		    			<td>基准:</td>
		    			<td>
		    				<input name="base" type="text" value="">
						</td>
						<td>*测量值</td>
		    		</tr>
		    		<tr>
		    			<td>波动:</td>
		    			<td>
		    				<input name="scope" type="text" value="">
						</td>
						<td>*测量值</td>
		    		</tr>		    		
		    		<tr>
		    			<td>步进:</td>
		    			<td>
		    				<input name="step" type="text" value="">
						</td>
						<td>*测量值</td>
		    		</tr>	
		    		<tr>
		    			<td>启用:</td>
		    			<td>
		    				<input id="enabled" name="enabled" type="text" value="">
						</td>
						<td>*测量值</td>
		    		</tr>		    		
		    	</table>
		    </form>
	    
	    </div>
	    
	    <div style="padding:5px 60px 5px 60px">
		
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" style="width:80px" onclick="start()">启动</a>
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" style="width:80px" onclick="stop()">停止</a>
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" style="width:80px" onclick="upBase()">基准上调</a>
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" style="width:80px" onclick="downBase()">基准下调</a>
			
		</div>	
	    
	</div>

	<div class="easyui-panel" title="运行状态" style="width:600px">
		
		<div style="margin:5px 5px;">

		<input id="runtime" class="easyui-textbox" data-options="multiline:true" disabled="disabled" value="" style="width:100%;height:1000px">
		
		</div>
		
	</div>

</body>
</html>